package roborally.Pieces;
import be.kuleuven.cs.som.annotate.*;

/**
 * This is a class representing a Wall on the Board with a Position and which can be terminated.
 * @invar 	The position is valid 
 * 			| Position.isValidPosition(getPosition().getX(), getPosition().getY(), getPosition().getBoard() )
 * @version 3.0
 * @author 	Bart Opsomer 2de Bachelor Ingenieurswetenschappen Electrotechniek-Computerwetenschappen 
 * 		  	Peter Opsomer 1ste Master Wiskundige IngenieursTechnieken
 */
public class Wall extends GamePieceWithoutOrientation {
	/**
	 * Create a new non-terminated Wall with no initial Position.
	 * 
	 * @effect  | super()
	 */
	@Raw
	public Wall(){
		super();
	}
	/**
	 * Get a String representation of this Object.
	 * 
	 * @return  | result.equals("Wall " + super.toString() )
	 */
	public String toString() {
		return "Wall" + super.toString();
	}
	/**
	 * Overrides the default shootThis-method from GamePiece
	 * Shooting a Wall has no effect
	 * @post	no effect for the wall
	 * 			| new = this
	 */
	@Override
	public void shootThis() {
		// shooting a wall has no effect
	}
	/**
	 * Terminates this Wall and removes it from the Board
	 * @post	This Wall is terminated
	 * 			| new.isTerminated()
	 * @post    The Wall is removed from the Board
	 * 			| !(new this.getPosition().getBoard() ).hasWallAt(this.getPosition() )
	 */
	@Override
	public void terminate() {
		// No Board should contain terminated GamePieces.
		if(getPosition() != null) {
			getPosition().getBoard().removeWall(this);
			// setPosition(null); is already done in Board.removeWall
		}
		super.terminate();
	}
}
